package net.zwj.hadoop.mapred;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class MaxTemperatureMapper extends
		Mapper<LongWritable, Text, Text, IntWritable> {

	@Override
	protected void map(LongWritable key, Text value, Context context)
			throws IOException, InterruptedException {
		String line = value.toString();
		String[] temps = line.split(" ");
		if (temps != null && temps.length == 2) {
			String year = temps[0];
			int temperature = Integer.parseInt(temps[1]);
			context.write(new Text(year), new IntWritable(temperature));
		}
	}
}
